package cn.yangliu.nacos.management.repository.sys;

import cn.yangliu.jpa.base.repository.BaseRepository;
import cn.yangliu.nacos.management.entity.sys.User2Role;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
public interface User2RoleRepository extends BaseRepository<User2Role, User2Role.User2RoleKey> {

    /**
     * Delete by role id.
     *
     * @param roleId the role id
     */
    @Query("delete from User2Role where id.roleId=:roleId")
    @Modifying
    void deleteByRoleId(Long roleId);

    /**
     * Delete by user id.
     *
     * @param userId the user id
     */
    @Query("delete from User2Role where id.userId=:userId")
    @Modifying
    void deleteByUserId(Long userId);
}
